#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QtSql>
#include <QDeclarativeContext>
#include <QDebug>
#include "medicsmodel.h"
#include "afsapsparser.h"


Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));



    //AfsapsParser * parser = new AfsapsParser;

    //parser->setSource("http://afssaps-prd.afssaps.fr/php/ecodex/rcp/R0193580.htm");

    QFileInfo info("qml/medico/afsaps.sqlite");

   qDebug()<<"exist "<<info.exists();
qDebug()<<info.absoluteFilePath();

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(QDir::toNativeSeparators(info.absoluteFilePath()));
    bool ok = db.open();


    qDebug()<<"open"<<ok;

    MedicsModel *w = new MedicsModel;
    w->load("");


    QmlApplicationViewer viewer;

    viewer.setMainQmlFile(QLatin1String("qml/medico/main.qml"));
    viewer.rootContext()->setContextProperty("medicsmodel", w);

    viewer.showExpanded();


    return app->exec();
}
